/*
 * MIT License
 *
 * Copyright (c) 2023 北京凯特伟业科技有限公司
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
//package com.je.demo.test.service.impl;
//
//import com.alibaba.fastjson2.JSON;
//import com.alibaba.fastjson2.JSONObject;
//import com.je.common.base.service.MetaService;
//import com.je.common.base.util.StringUtil;
//import com.je.meta.entity.ActionDataSourceVo;
//import com.je.meta.rpc.dataSource.DataSourceRpcService;
//import org.apache.servicecomb.provider.pojo.RpcSchema;
//import org.springframework.beans.factory.annotation.Autowired;
//import java.util.List;
//import java.util.Map;
//
//
//@RpcSchema(schemaId = "actionDataSourceDemo")
//public class ActionDataSourceDemo implements DataSourceRpcService {
//    @Autowired
//    private MetaService metaService;
//    @Override
//    public List<Map<String, Object>> queryData(ActionDataSourceVo actionDataSourceVo) {
//        /*ConditionsWrapper conditionsWrapper = ConditionsWrapper.builder();
//        conditionsWrapper.and(i->{
//            JSONObject jsonObject = new JSONObject();
//            if(StringUtil.isNotEmpty(actionDataSourceVo.getParameterStr())){
//                jsonObject = JSON.parseObject(actionDataSourceVo.getParameterStr());
//            }
//            for(Map.Entry<String,Object> entry:jsonObject.entrySet()){
//                i.eq(StringUtil.isNotEmpty(entry.getValue()),entry.getKey(),entry.getValue());
//            }
//        });
//        if(StringUtil.isNotEmpty(conditionsWrapper.getSql())){
//            conditionsWrapper.apply(actionDataSourceVo.getLimit()!=0," LIMIT "+actionDataSourceVo.getLimit());
//        }
//        conditionsWrapper.table("CRM_KHGL");
//        conditionsWrapper.groupBy("KHGL_XXLY_CODE");*/
//        String AllDataSql = "SELECT KHGL_XXLY_CODE,KHGL_XXLY_NAME ,count(*) as totalCount FROM crm_khgl  GROUP BY KHGL_XXLY_CODE";
//        String querySQL = "SELECT KHGL_XXLY_CODE,KHGL_XXLY_NAME ,count(*) as totalCount FROM crm_khgl WHERE KHGL_XXLY_CODE='%s'  GROUP BY KHGL_XXLY_CODE";
//        JSONObject jsonObject = new JSONObject();
//        if(StringUtil.isNotEmpty(actionDataSourceVo.getParameterStr())){
//            jsonObject = JSON.parseObject(actionDataSourceVo.getParameterStr());
//        }
//        if(StringUtil.isNotEmpty(jsonObject.getString("KHGL_XXLY_CODE"))){
//            querySQL = String.format(querySQL,jsonObject.getString("KHGL_XXLY_CODE"));
//            return metaService.selectSql(querySQL);
//        }
//        return metaService.selectSql(AllDataSql);
//    }
//}
